
package main

import "fmt"

func two_sum(nums []int, target int) []int {
	s := make([]int,2)
	for i:=0; i<len(nums); i++ {
		for j:=i+1; j<len(nums); j++ {
			if nums[i] + nums[j] == target {
				s[0] = i
				s[1] = j
			}
		}
	}
	return s
}

func two_sum_1(nums []int, target int) []int {
	//var s []int
	s := make([]int, 2)
	//var temp map[int]int
	temp := make(map[int]int, len(nums))
	for i:=0; i<len(nums); i++ {
		dec := target - nums[i]
		if value, ok := temp[dec]; ok {
			s[0] = value 
			s[1] = i
		} else {
			temp[nums[i]] = i
		}
	}
	return s
}

func main(){
	fmt.Printf("hello, world\n")
	nums := []int{0,2,4,0}
	target := 6
	fmt.Println(two_sum(nums, target))
	fmt.Println(two_sum_1(nums, target))
}
